{% set clazz = "process" %}
{% set title = "处理中，请稍后" %}
{% extends './modules/common/templates/main.html' %}
{% block style %}
{% endblock %}
{% block content %}
  {% if !nested %}
    <header class="bar bar-header">
      {{ macro.back() }}
      <h1 class="title">{{ title }}</h1>
    </header>
  {% endif %}
  <div class="plate">
    <div class="draw">
      <img src="http://7xjyap.com2.z0.glb.qiniucdn.com/image-91cb67da-2764-4573-afee-e366b2756c3c.png" alt="请稍后">
      <h4 class="title">处理中，请稍后...</h4>
      <input name="id" type="hidden" value="{{id}}">
      <input name="code" type="hidden" value="{{code}}">
      <input name="optType" type="hidden" value="{{optType}}">
    </div>
  </div>
{% endblock %}
{% block script %}
  {% parent %}
  <script>
   
    if($('[name=code]').val() == localStorage.getItem('delivery_code')){

      $.get('/delivery/code/isvalid', {
        id: $('[name=id]').val(),
        optType: $('[name=optType]').val()
      }).then(function(res){
        location.href = '/delivery/successpage?code=' + $('[name=code]').val();
      },function(rej){
        location.href = '/delivery/error?error_message=' + rej.message;
      })
    }else{
      location.href = '/delivery/error?error_message=无效二维码，请检查该配送单的二维码'
    }
    
  </script>
{% endblock %}
